package org.mzx.shortLink.adminn.common.config;

import lombok.RequiredArgsConstructor;
import org.mzx.shortLink.adminn.common.Interceptor.loginInterceptor;
import org.mzx.shortLink.adminn.common.Interceptor.userFlowRiskLimitInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
@RequiredArgsConstructor
public class SpringMVCconfig implements WebMvcConfigurer {
    private final loginInterceptor logininterceptor;

    private final userFlowRiskLimitInterceptor userFlowRiskLimitInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(logininterceptor).excludePathPatterns(
                "/api/short-link/admin/v1/user",
                "/api/short-link/admin/v1/user/login",
                "/api/short-link/admin/v1/user/has-username"
        ).order(1);
        registry.addInterceptor(userFlowRiskLimitInterceptor).addPathPatterns(
                "/api/short-link/admin/v1/*"
        ).order(10);
    }
}
